<?php

/**
 * View :: JSON (Java Script Object Notation)
 * 
 * Mainly for ajax style applications this view will simply render the
 * model in the JSON format.
 *
 * Warlock is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 *
 * @package    warlock`
 * @author     David Cole <neophyte@sourcetutor.com>
 * @license    GNU/GPL v2
 */

// File Dependencies
using('Views.IView');
using('Library.PEAR.Services.JSON');

class View_JSON extends IView
{
    /**#@+
     * Required Core Objects
     *
     * These are references to the core objects required by this
     * class.
     *
     * @access private
     * @var    object
     */    
    var $_Error;
    var $_Profiler;
    var $_Model;
    /**#@-*/
    
    /**
     * Output Buffer
     *
     * @var string
     * @access private
     */
    var $_Output;

    /**
     * Constructor
     *
     * Initialise the view ready for rendering.
     * 
     * @return void
     */
    function __construct()
    {
        // Call the IView Constructor
        parent::__construct();
        
        // Reference Required Objects
        $this->_Error    = &Vault::Get('Debug_Error');
        $this->_Profiler = &Vault::Get('Debug_Profiling');
        $this->_Model    = &Vault::Get('Model');
    }

    /**
     * Render Page Model
     *
     * @access public
     */
    function Render()
    {
        $json = new Services_JSON();
        $this->_Output = $json->encode($this->_Model->Get('Page'));
    }

    /**
     * Display Output Buffer
     *
     * @access public
     */
    function Output()
    {
        echo $this->_Output;
    }
}

?>